package com.v5ba;

import com.v5ba.event.EditUser;
import com.v5ba.event.EditUserEvent;
import com.v5ba.event.EditUserListener;
import com.v5ba.event2.AddUser;
import com.v5ba.event2.AddUserEvent;
import com.v5ba.event2.AddUserListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@SpringBootApplication
public class StartApplication {

	public static void main(String[] args) {
		SpringApplication.run(StartApplication.class, args);
	}

	@Bean
	public ApplicationListener editUserListener(){
		return (ApplicationListener<EditUserEvent>) event -> {
			EditUser editUser = (EditUser) event.getSource();
			System.out.println("editUserListener:" + editUser.getName());
		};
	}
}
